Micron Document
🎖️GitЯра🎖️

Node / meshtastic / Meshtastic-Android / files / androidApp / src / google / kotlin / org / meshtastic / app / map / component / NodeClusterMarkers.kt

Displaying Raw • Download

androidApp/src/google/kotlin/org/meshtastic/app/map/component/NodeClusterMarkers.kt 7df0ee08e520a0c9846d20ffbcd643c6b6dee6ec (7df0ee08) Text, 4.50 KB

T8b949e/*
* Copyright (c) 2026 Meshtastic LLC
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
Tff7b72package T7ee787org.meshtastic.app.map.component

Tff7b72import T7ee787androidx.compose.runtime.Composable
Tff7b72import T7ee787androidx.compose.runtime.SideEffect
Tff7b72import T7ee787androidx.compose.ui.graphics.Color
Tff7b72import T7ee787androidx.compose.ui.platform.LocalView
Tff7b72import T7ee787androidx.lifecycle.compose.LocalLifecycleOwner
Tff7b72import T7ee787androidx.lifecycle.findViewTreeLifecycleOwner
Tff7b72import T7ee787androidx.lifecycle.setViewTreeLifecycleOwner
Tff7b72import T7ee787androidx.savedstate.compose.LocalSavedStateRegistryOwner
Tff7b72import T7ee787androidx.savedstate.findViewTreeSavedStateRegistryOwner
Tff7b72import T7ee787androidx.savedstate.setViewTreeSavedStateRegistryOwner
Tff7b72import T7ee787com.google.maps.android.clustering.Cluster
Tff7b72import T7ee787com.google.maps.android.clustering.view.DefaultClusterRenderer
Tff7b72import T7ee787com.google.maps.android.compose.Circle
Tff7b72import T7ee787com.google.maps.android.compose.MapsComposeExperimentalApi
Tff7b72import T7ee787com.google.maps.android.compose.clustering.Clustering
Tff7b72import T7ee787com.google.maps.android.compose.clustering.ClusteringMarkerProperties
Tff7b72import T7ee787org.meshtastic.app.map.model.NodeClusterItem
Tff7b72import T7ee787org.meshtastic.feature.map.BaseMapViewModel

Tf0883e@OptInTb4b4b4(Te6edf3MapsComposeExperimentalApiTff7b72::Te6edf3classTb4b4b4)
Tf0883e@SuppressTb4b4b4(Ta5d6ff"Ta5d6ffNestedBlockDepthTa5d6ff"Tb4b4b4)
Tf0883e@Composable
Tff7b72fun Td2a8ffNodeClusterMarkersTb4b4b4(
Te6edf3nodeClusterItemsTb4b4b4: Te6edf3ListTff7b72<Te6edf3NodeClusterItemTff7b72>Tb4b4b4,
Te6edf3mapFilterStateTb4b4b4: Te6edf3BaseMapViewModelTb4b4b4.Te6edf3MapFilterStateTb4b4b4,
Te6edf3navigateToNodeDetailsTb4b4b4: Tb4b4b4(Tffa657IntTb4b4b4) Tff7b72-Tff7b72> Tffa657UnitTb4b4b4,
Te6edf3onClusterClickTb4b4b4: Tb4b4b4(Te6edf3ClusterTff7b72<Te6edf3NodeClusterItemTff7b72>Tb4b4b4) Tff7b72-Tff7b72> Tffa657BooleanTb4b4b4,
Tb4b4b4) Tb4b4b4{
Tff7b72val Te6edf3view Tff7b72= Te6edf3LocalViewTb4b4b4.Te6edf3current
Tff7b72val Te6edf3lifecycleOwner Tff7b72= Te6edf3LocalLifecycleOwnerTb4b4b4.Te6edf3current
Tff7b72val Te6edf3savedStateRegistryOwner Tff7b72= Te6edf3LocalSavedStateRegistryOwnerTb4b4b4.Te6edf3current

T8b949e// Workaround for https://github.com/googlemaps/android-maps-compose/issues/858
T8b949e// and https://github.com/googlemaps/android-maps-compose/issues/875
T8b949e// The maps clustering library creates an internal ComposeView to snapshot markers.
T8b949e// If that view is not attached to the hierarchy (which it often isn't during rendering),
T8b949e// it fails to find the Lifecycle and SavedState owners. We propagate them to the root view
T8b949e// so the internal snapshot view can find them when walking up the tree.
T8b949e// We do this in a SideEffect to ensure it happens before or during composition of children.
Te6edf3SideEffect Tb4b4b4{
Tff7b72val Te6edf3root Tff7b72= Te6edf3viewTb4b4b4.Te6edf3rootView
Tff7b72if Tb4b4b4(Te6edf3rootTb4b4b4.Te6edf3findViewTreeLifecycleOwnerTb4b4b4(Tb4b4b4) Tff7b72=Tff7b72= Tff7b72nullTb4b4b4) Tb4b4b4{
Te6edf3rootTb4b4b4.Te6edf3setViewTreeLifecycleOwnerTb4b4b4(Te6edf3lifecycleOwnerTb4b4b4)
Tb4b4b4}
Tff7b72if Tb4b4b4(Te6edf3rootTb4b4b4.Te6edf3findViewTreeSavedStateRegistryOwnerTb4b4b4(Tb4b4b4) Tff7b72=Tff7b72= Tff7b72nullTb4b4b4) Tb4b4b4{
Te6edf3rootTb4b4b4.Te6edf3setViewTreeSavedStateRegistryOwnerTb4b4b4(Te6edf3savedStateRegistryOwnerTb4b4b4)
Tb4b4b4}
Tb4b4b4}

Te6edf3ClusteringTb4b4b4(
Te6edf3items Tff7b72= Te6edf3nodeClusterItemsTb4b4b4,
Te6edf3onClusterClick Tff7b72= Te6edf3onClusterClickTb4b4b4,
Te6edf3onClusterItemInfoWindowClick Tff7b72= Tb4b4b4{ Te6edf3item Tff7b72-Tff7b72>
Te6edf3navigateToNodeDetailsTb4b4b4(Te6edf3itemTb4b4b4.Te6edf3nodeTb4b4b4.Te6edf3numTb4b4b4)
Tff7b72false
Tb4b4b4}Tb4b4b4,
Te6edf3clusterItemContent Tff7b72= Tb4b4b4{ Te6edf3clusterItem Tff7b72-Tff7b72> Te6edf3PulsingNodeChipTb4b4b4(Te6edf3node Tff7b72= Te6edf3clusterItemTb4b4b4.Te6edf3nodeTb4b4b4) Tb4b4b4}Tb4b4b4,
Te6edf3onClusterManager Tff7b72= Tb4b4b4{ Te6edf3clusterManager Tff7b72-Tff7b72>
Tb4b4b4(Te6edf3clusterManagerTb4b4b4.Te6edf3renderer Tff7b72as Te6edf3DefaultClusterRendererTb4b4b4)Tb4b4b4.Te6edf3minClusterSize Tff7b72= T79c0ff1T79c0ff0
Tb4b4b4}Tb4b4b4,
Te6edf3clusterItemDecoration Tff7b72= Tb4b4b4{ Te6edf3clusterItem Tff7b72-Tff7b72>
Tff7b72if Tb4b4b4(Te6edf3mapFilterStateTb4b4b4.Te6edf3showPrecisionCircleTb4b4b4) Tb4b4b4{
Te6edf3clusterItemTb4b4b4.Te6edf3getPrecisionMetersTb4b4b4(Tb4b4b4)Tff7b72?.Te6edf3let Tb4b4b4{ Te6edf3precisionMeters Tff7b72-Tff7b72>
Tff7b72if Tb4b4b4(Te6edf3precisionMeters Tff7b72> T79c0ff0Tb4b4b4) Tb4b4b4{
Te6edf3CircleTb4b4b4(
Te6edf3center Tff7b72= Te6edf3clusterItemTb4b4b4.Te6edf3positionTb4b4b4,
Te6edf3radius Tff7b72= Te6edf3precisionMetersTb4b4b4,
Te6edf3fillColor Tff7b72= Te6edf3ColorTb4b4b4(Te6edf3clusterItemTb4b4b4.Te6edf3nodeTb4b4b4.Te6edf3colorsTb4b4b4.Te6edf3secondTb4b4b4)Tb4b4b4.Te6edf3copyTb4b4b4(Te6edf3alpha Tff7b72= T79c0ff0.2fTb4b4b4)Tb4b4b4,
Te6edf3strokeColor Tff7b72= Te6edf3ColorTb4b4b4(Te6edf3clusterItemTb4b4b4.Te6edf3nodeTb4b4b4.Te6edf3colorsTb4b4b4.Te6edf3secondTb4b4b4)Tb4b4b4,
Te6edf3strokeWidth Tff7b72= T79c0ff2fTb4b4b4,
Te6edf3zIndex Tff7b72= T79c0ff0fTb4b4b4,
Tb4b4b4)
Tb4b4b4}
Tb4b4b4}
Tb4b4b4}
T8b949e// Use the item's own priority-based zIndex (5f for My Node/Favorites, 4f for others)
Te6edf3ClusteringMarkerPropertiesTb4b4b4(Te6edf3zIndex Tff7b72= Te6edf3clusterItemTb4b4b4.Te6edf3getZIndexTb4b4b4(Tb4b4b4)Tb4b4b4)
Tb4b4b4}Tb4b4b4,
Tb4b4b4)
Tb4b4b4}

Served by rngit 1.5.0 - Generated in 0.07s